package usaco.c2010.march.bronze;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.concurrent.ArrayBlockingQueue;

/*
 * p3599
 * USACO 2010 March - Bronze
 */

public class p3599 {

	static String inum;
	static Queue<Integer> q;
	static Stack<Integer> s;
	static int count;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		inum = scanner.next();
		int l = inum.length();
		q = new ArrayBlockingQueue<Integer>(l*5 + 5);
		count = 0;
		for (int i=l-1;i>=0;--i) {
			char c = inum.charAt(i);
			int num = getNum(c);
			for (int j=0;j<4;++j) {
				int re = num % 2;
				num /= 2;
				q.add(re);
				count++;
			}
		}
		int up = (3 - (count % 3)) % 3;
		for (int i=0;i<up;++i) {
			q.add(0);
		}
		s = new Stack<Integer>();
		while (!q.isEmpty()) {
			int a, b, c, oc;
			c = q.poll();
			b = q.poll();
			a = q.poll();
			oc = c * 1 + b * 2 + a * 4;
			s.push(oc);
		}
		while (!s.isEmpty()) {
			int t = s.peek();
			if (t == 0) {
				s.pop();
			}
			else {
				break;
			}
		}
		if (s.isEmpty()) {
			System.out.println(0);
		}
		else {
			while (!s.isEmpty()) {
				System.out.print(s.pop());
			}
			System.out.println();
		}
	}

	private static int getNum(char c) {
		if (c >= '0' && c <= '9') {
			return (int) (c - '0');
		}
		else {
			return (int) (c - 'A' + 10);
		}
	}

}
